package com.itheima.mapper;

import com.itheima.entity.Dish;
import com.itheima.entity.Emp;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DishMapper {
    //添加菜品信息
    @Insert("insert into dish.dish(id, name, category_id, price, image, description, status, create_time, update_time, create_user, update_user) " +
            "values (null,#{name},#{categoryId},#{price},#{image},#{description},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser});")
    void save(Dish dish);
    // 根据id
    @Select("select *from dish.dish where id = #{id}")
    Emp queryOne(Integer id);

    @Update("update dish.dish set name=#{name}, category_id=#{categoryId}, price=#{price}, image=#{image}, " +
            "description=#{description}, status=#{status}, create_time=#{createTime}, update_time=#{updateTime}, " +
            "create_user=#{createUser}, update_user=#{updateUser} where id=#{id}")
    void update(Dish dish);

    void delete(List<Integer> ids);

    @Update("update dish.dish set status=#{staus} where id = #{id}")
    void startOrStop(Integer status, Integer id);
    // 分页查询
    @Select("select count(*) from dish.dish")
    Integer count();
    // 分页查询
    @Select("select *from dish.dish limit #{page},#{pageSize}")
    List<Class> pageQuery(Integer page, Integer pageSize);
}
